"use strict"
var call = require("../../utils/request.js")
const app = getApp()
Page({
  data: {
    indicatorDots: true,
    interval: 2000,
    duration: 500,
    time: "请选择入住时间",
    // navLists: ['设施与服务', '预订须知', '酒店介绍', '查看房型'],
    tabId: 'tab_0',
    isFixedNav: false,
    scrollTop: 0,
    detail: [],
    viewHeight: 0,
    toView: '',
    detail:[]
  },

  onLoad: function (e) {
    wx.setNavigationBarTitle({
      title: '酒店详情'
    })

    
    var url = 'getHdetail?hid=' + e.hid;
    call.getData(url, this.getHdetail, this.fail)

    // var url2 = 'getHdetail?hid=32';
    // call.getData(url, this.getHdetail, this.fail)


    let systemInfo = wx.getSystemInfoSync()
    let screenWidth = systemInfo.screenWidth
    this.swiperHeight = screenWidth * 8 / 15
    this.setData({
      hid: e.hid,
      viewHeight: systemInfo.windowHeight - 50
    })
  },
  getHdetail: function (e) {
    console.log(e)
    this.setData({
      detail: e.data

    })


  },
  gohome: function (data) {
    wx.reLaunch({
      url: '../index/index',
    })
  },

  gotodetail: function(e) {
    console.log(213)
    console.log(e.currentTarget.dataset.item)
    wx.redirectTo({
      url: '../detail/detail?roomid=' + e.currentTarget.dataset.item
    })
  },
  
  toOrder: function(e) {
    console.log(this.data.detail.h_tel)
    wx.makePhoneCall({
      phoneNumber: this.data.detail.h_tel,
    })
    // wx.reLaunch({
    //   url: '../index/index',
    // })
  },
  changeNav: function (e) {
    this.tabId = e.currentTarget.id
    this.setData({
      tabId: this.tabId,
      toView: this.tabId
    })
  },

  pageScroll: function (e) {
    let scrollTop = e.detail.scrollTop
    let isFixedNav = scrollTop > this.swiperHeight ? true : false
    this.setData({
      isFixedNav
    })
  },

})